#!c:\python25\python.exe

from xml.dom import minidom
from xmlData import *
from string import *

fp = open(r"f:\eclipse-jee\topcard\src\tools\ctdt110001_rpt.xml", "r")
#content = fp.read()
#fp.close()
#content = content.decode("gb2312").encode("utf-8")
#content = content.replace("encoding='gb2312'", "encoding='UTF-8'")
#dom = minidom.parseString(content)
dom = minidom.parse(fp)
root = dom.documentElement

DictDetail = CAllData()

for DetailNode in root.getElementsByTagName("detail"):
	for DataNode in DetailNode.childNodes:
		if DataNode.nodeName == "data" :
			dict = CSingleData()
			for attrKey, attrValue in DataNode.attributes.items() :
				if attrKey == "group" :
					dict.setValue("group", int(str(attrValue)))

			for ChildDataNode in DataNode.childNodes :
				if ChildDataNode.nodeType == ChildDataNode.ELEMENT_NODE :
					strValue = ChildDataNode.childNodes[0].data
					if ChildDataNode.nodeName == "length" :
						if strValue.find(",") == -1 :
							dict.setValue("length", int(strValue))
						else :
							dupLen = split(strValue, ",")
							dict.setValue("length", int(dupLen[0]))
							dict.setValue("dotLen", int(dupLen[1]))
					else :
						dict.setValue(ChildDataNode.nodeName, strValue)
			DictDetail.addData(dict.getValue("variable"), dict)

DictDetail.printValue()

fp.close()
